package com.itheima.exer.exercise.ex0928.test;

import com.itheima.exer.exercise.ex0928.doman.Teacher;

import java.text.Collator;
import java.util.*;

public class SetTeacher1 {
    public static void main(String[] args) {
        Set<Teacher> st = new TreeSet<>(new Comparator<Teacher>() {
            @Override
            public int compare(Teacher o1, Teacher o2) {
                int result = (o1.getChinese() + o1.getMath()) - (o2.getChinese() + o2.getMath());
                if (result == 0) {
                    result = o1.getChinese() - o2.getChinese();
                }
                if (result == 0) {
                    result = o1.getMath() - o2.getMath();
                }
                if (result == 0) {
                    result = o1.getAge() - o2.getAge();
                }
                if (result == 0) {
                    Collator collator = Collator.getInstance(Locale.CHINA);
                    result =  collator.compare(o1.getName(),o2.getName());
                }
                return result;
            }
        });
        st.add(new Teacher("张三",28,98,98));
        st.add(new Teacher("王五",24,80,60));
        st.add(new Teacher("赵六",29,60,80));
        st.add(new Teacher("李四",25,98,98));
        st.add(new Teacher("田七",21,91,91));
        st.add(new Teacher("因伤",30,98,60));
        st.add(new Teacher("张三",18,60,98));
        Iterator<Teacher> iterator = st.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
    }
}
